<?php echo $html->css("screen/staff_parts.css");?>
<?php echo $html->css("screen/swfupload.css");?>
<?php echo $javascript->link("lib/swfupload/swfupload.js");?>
<?php echo $javascript->link("lib/swfupload/swfupload.queue.js");?>
<?php echo $javascript->link("lib/swfupload/swfupload.setting.js");?>
<?php echo $javascript->link("lib/swfupload/fileprogress.js");?>
<?php echo $javascript->link("lib/swfupload/handlers.js");?>
<?php echo $this->element('menu', array("active" => "2.c"));?>
<ul class="breadcrumb">
<li>
  <?php echo $this->Html->link(__('Shop  ', true), array('action' => 'index', 'controller' => 'parts'), array('class'=>'fist_link'));?>
</li>
<li>          
  <?php echo $this->Html->link(__('Categories  ', true), array('action' => 'index'));?>
</li>
</ul>
<script>
var PATHUPLOAD="<?php echo $this->webroot;?>files/uploads/<?php echo $pathupload;?>/";
var FOLDERUPLOAD="<?php echo $pathupload;?>/";
var FILEUPLOAD="<?php echo $fileupload;?>";
var swfu;
var settings= {
	flash_url : "<?php echo $this->webroot;?>js/lib/swfupload/swfupload.swf",
	upload_url: "<?php echo $this->webroot;?>files/swfupload.php",
	post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
	post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},

	// File Upload Settings
	file_size_limit : "500",	// 200 kb
	file_types : "*.jpg;*.gif;*.png",
	file_types_description : "Image Files",				
	file_upload_limit : 10,
	file_queue_limit : 0,
	custom_settings : {
		progressTarget : "fsUploadProgress",
		cancelButtonId : "btnCancel"
	},
	debug: false,

	// Button settings
	button_image_url: "<?php echo $this->webroot;?>js/lib/swfupload/bg.png",
	button_text : "<span class=\"upload_text\">Upload photo</span>",
	button_text_style : ".upload_text { color:#FFFFFF;font-size:12px;text-align:center;}", 
	button_text_top_padding : 6, 
	button_class: "upload_button",				
	button_placeholder_id : "spanButtonPlaceHolder",
	button_width: 120,
	button_height: 28,
	
	// The event handler functions are defined in handlers.js
	file_queued_handler : fileQueued,
	file_queue_error_handler : fileQueueError,
	file_dialog_complete_handler : fileDialogComplete,
	upload_start_handler : uploadStart1,
	upload_progress_handler : uploadProgress,
	upload_error_handler : uploadError1,
	upload_success_handler : uploadSuccess1,
	upload_complete_handler : uploadComplete,
	queue_complete_handler : queueComplete	// Queue plugin event
};
function uploadSuccess_init() {
	try {		
		fileuploaded = FILEUPLOAD+'<?php echo $extension;?>';
		$("#thumbnail").html('<a class="upload_close" href="#" target="_self" onclick="cancelUpload();return false;">&nbsp;&nbsp;</a><img src="'+PATHUPLOAD+fileuploaded+'" class="thumbnail" />');
		$("#PartCategoryPhoto").val(fileuploaded);
		$("#upload").hide();		
		progress.toggleCancel(false);		
	} catch (ex) {
		
	}
}
</script>
<script>	
	$(document).ready(function(){		
		$("#PartCategoryAdminEditForm").validate({
			rules: {
				'data[PartCategory][category]': {
					required: true,
					minlength: 3
				}
			},
			messages: {			
				'data[PartCategory][category]': {
					required: "Please enter a Category title",
					minlength: "This title must consist of at least 3 characters"
				}
			}
		});
		$('.jqTransform').jqTransform({width:100});	
		swfu = new SWFUpload(settings);
		uploadSuccess_init();
	});
</script>	
  
<div id="content" class="partCategories form">	
<?php echo $this->Form->create('PartCategory');?>
	<fieldset>
 		<table><tr><td>
	<label class="upload" for="PartCategoryPhoto">Photo</label>
	</td><td>
	<!--upload-->
		<div id="thumbnail"></div>					
		<div id="upload">
			<span id="spanButtonPlaceHolder"></span>
			<input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px; display:none;" />
		</div>
	<!--upload-->
	</td></tr>
	<tr><td></td><td width="100%">
	<div id="divStatus" style="display:none;">0 Files Uploaded</div>
		<div class="fieldset flash" id="fsUploadProgress">
			<span class="legend">Upload Queue</span>
		</div></td></tr>
	<tr><td colspan="2">
		<input type="hidden" id="PartCategoryPhoto" maxlength="1024" name="data[PartCategory][photo]">
	<?php
		echo $this->Form->input('id');		
		echo $this->Form->input('category');
		echo '<span class="jqTransform">';
		echo $this->Form->input('type');
		echo '</span>';
	?>
	<div class="clear">
		<?php echo $form->submit(__('Save', true),array('class'=>'bt bt_save','div'=>false));?>
	</div>	 
	</td></tr>
	</table>
	</fieldset>
	<?php echo $this->Form->end();?>
	
</div>